﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FrasesSimpsonsMvc.Models;

namespace FrasesSimpsonsMvc.Controllers
{
    public class TemporadaController : BaseController
    {

        public TemporadaController() : base() { }

        public ActionResult Index()
        {
            var temporadas = from t in Context.Temporadas
                             select t;

            return View(temporadas.ToList());
        }

        public ActionResult Detail(int? id)
        {
            if (!id.HasValue)
                return RedirectToAction("Index");

            var temporada = (from t in Context.Temporadas
                             where t.Id == id.Value
                             select t).FirstOrDefault();

            if (temporada == null)
                return RedirectToAction("Index");

            temporada.LoadRelatedEntities();

            return View(temporada);
        }

    }
}
